package task;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import database.Database;

public class TaskCtrl {
	
	public static void closeConcerningTasks(int cid) {

		try {
			Connection con = Database.getConnection();
			Statement stmt = con.createStatement();

			stmt.executeUpdate(String.format(
					"update task " +
					"set state = %d " +
					"where channelThisType = %d or channelThatType = %d",
					Task.DELETED, cid, cid));
			
			stmt.close();
			con.close();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
